﻿using System.ComponentModel;
using System.Runtime.CompilerServices;

namespace Library.Classes
{
    internal class Client : INotifyPropertyChanged
    {
        #region Интерфейс INotifyPropertyChanged
        public event PropertyChangedEventHandler? PropertyChanged;

        public void NotifyPropertyChanged([CallerMemberName] string propertyName = "")
        {
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
        }
        #endregion

        private int _id = 0;
        private string _firstName = "None"; // Фамилия читателя
        private string _lastName = "None";  // Имя читателя
        private DateTime _birthday;         // Дата рождения
        private string _phone = "0";        // Номер телефона
        private string _email = "";         // Электронная почта
        private bool is_active = true;          // Активен ли читатель: 1 - да, 0 - нет

        public int Id
        {
            get { return _id; }
            set {
                _id = value;
                NotifyPropertyChanged();
            }
        }

        public string FirstName
        {
            get { return _firstName; }
            set { 
                _firstName = value;
                NotifyPropertyChanged(); 
            }
        }

        public string LastName
        {
            get { return _lastName; }
            set { 
                _lastName = value; 
                NotifyPropertyChanged(); 
            }
        }

        public DateTime Birthday
        {
            get { return _birthday; }
            set { 
                _birthday = value; 
                NotifyPropertyChanged(); 
            }
        }

        public string Phone
        {
            get { return _phone; }
            set { 
                _phone = value; 
                NotifyPropertyChanged();
            }
        }

        public string Email
        {
            get { return _email; }
            set {
                _email = value;
                NotifyPropertyChanged();
            }
        }

        public bool Status { get => is_active; set => is_active = value; }

        public Client(int id, string lastName, string firstName, DateTime birthday, string phone, string email, bool status) 
        {
            Id = id;
            LastName = lastName;
            FirstName = firstName;
            Birthday = birthday;
            Phone = phone;
            Email = email;
            Status = status;
        }

        public override string ToString()
        {
            return $"{LastName} {FirstName}";
        }
    }
}
